<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"  %>
<html>
	<head>
		<meta charset="utf-8" />
		<title>${sys.web_name}</title>
	    <link href="../statics/css/front/info.css" rel="stylesheet" />
	     <script type="text/javascript" src="${path}/statics/js/jquery-1.8.3.js"></script>
	    <script type="text/javascript">
	    //收藏
	    var flag=${flag};
		  function sc(imgobj){
			  var member = "${member}";
			  if(member.length == 0){
				  alert("请先登录");
				  return;
			  }
			  
			  $.post("${path}/frontCtl/scart",{mebId:'${member.id}',artId:'${art.id}',flag:flag},function(res){
				  
			  })
			  
			  if(flag==0){//请求收藏
				  imgobj.src="${path}/statics/img/front/collectRed.png";
				  flag=1
			  }else{//取消收藏
				  imgobj.src="${path}/statics/img/front/collect.png";
				  flag=0
			  }
			  
			 
		  }
	    </script>
	</head>
	<body>
		<%@include file="top.jsp"%>
  
            	<!--文章详细信息-->
            	<div class="articleInfo">
            		  <!--标题-->
	            	  <div class="typeTitle">
	            	  	 <span class="titleSpan">${typeName}</span>
	            	  </div>
	            	   <!--内容-->
	            	  <div class="content">
					       <h3 style="text-align:center;">${art.title}</h3>
					       <div class="content_info">
					         作者/来源：${art.author}  
					         发表时间：  <fmt:formatDate value="${art.operTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
							  <!-- <img src="../../../statics/img/front/collect.png">-->
									<img src="${path}/statics/img/front/${flag==0?'collect.png':'collectRed.png'}"  onclick="sc(this)">
					       </div>
					         <p align="center">
					         	 ${art.content}
					         </p>
					       <br/>
					                 精彩评论：<br/>
					            <c:forEach items="${commentList}" var="comment"><p>
					            	<span style="color: black;">${comment.nickName}</span>&nbsp;
					             <span style="color:green;">
					              <fmt:formatDate value="${comment.commentTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
					                
					              </span>
					            <br/>
					              <span style="color:red;">
					                             ${comment.content}
					              </span></p>
					            </c:forEach>
					            <br/><br/>
					            <form action="" method="post">
					                 <input type="hidden" value="${member.id}" name="memberid" id="memberId">
					                 <input type="hidden" value="${art.id}" name="artid" id="artId">
					                 <textarea name="commentContent" id="commentContentId" cols="60" rows="5"></textarea>
					                 <br/>
					                 <c:if test="${member!=null}">
					                 <input type="submit" id="saveBtn" value="提交"/>
					                 </c:if>
					                  <c:if test="${member==null}">
					                 <a href="/frontCtl/toLogin">登录</a>
					                 </c:if>
					                 
					                 
					                  
					           </form>
					     </div>
					      
            	</div>
            	
              <%@include file="bottom.jsp"%>
              
              <script type="text/javascript" src="${path}/statics/js/jquery-1.8.3.js"></script>
		<script src="${path}/statics/layui/layui.js"></script>
		<script type="text/javascript">
			layui.use(['laydate', 'laypage','element','jquery','layer','upload',"table"], function(){
			  var element = layui.element;
			  var $ = layui.jquery;
			  var layer = layui.layer;
			  var upload = layui.upload;
			  var table = layui.table;
			  
			 
			  
			  
			  //发评论
			  $("#saveBtn").click(function(){
			  	   var memberId = $("#memberId").val();
				   var artId = $("#artId").val();
				   var commentContent = $("#commentContentId").val();
				  
				  $.post("${path}/frontCtl/saveComment",{memberId:memberId,artId:artId,commentContent:commentContent} ,function(res){
					  if (res==0) {
					  	layer.msg("提交成功" ,{icon:1} ,function(){
							location.reload();
						});
					  }else{
						  layer.msg("系统繁忙,请稍后" ,{icon:2})
					  }
				  })
				  
				  
				  
			  });
			  
			  //安全退出
			  $("#logOutBtn").click(function(){
			  	   layer.confirm('您确定要退出吗?', function(index){
			  		  location.replace("${path}/frontCtl/logOut");
			  		  layer.close(index);
			  		});  
			  });
			  
		
			});
		
		
		
		
		
		</script>	
	</body>
</html>